$(function() {

$("#roomsname").blur(
		function() {
			$("#roomsname_msg").empty();
			var name = $(this).val();
			if (name == "" || name == null) {
				$("#roomsname").after("<span id='roomsname_msg' style='color: red'>教室名称不能为空</span>");
			}
	});

$("#image").blur(
		function() {
			$("#image_msg").empty();
			var name = $(this).val();
			if (name == "" || name == null) {
				$("#image").after("<span id='image_msg' style='color: red'>图片不能为空</span>");
			}
	});

$("#cateid").blur(
		function() {
			$("#cateid_msg").empty();
			var name = $(this).val();
			if (name == "" || name == null) {
				$("#cateid").after("<span id='cateid_msg' style='color: red'>教室类型不能为空</span>");
			}
	});

$("#manager").blur(
		function() {
			$("#manager_msg").empty();
			var name = $(this).val();
			if (name == "" || name == null) {
				$("#manager").after("<span id='manager_msg' style='color: red'>教室负责人不能为空</span>");
			}
	});

$("#address").blur(
		function() {
			$("#address_msg").empty();
			var name = $(this).val();
			if (name == "" || name == null) {
				$("#address").after("<span id='address_msg' style='color: red'>教室地址不能为空</span>");
			}
	});

$("#contact").blur(
		function() {
			$("#contact_msg").empty();
			var name = $(this).val();
			if (name == "" || name == null) {
				$("#contact").after("<span id='contact_msg' style='color: red'>联系方式不能为空</span>");
			}
	});

$("#dept").blur(
		function() {
			$("#dept_msg").empty();
			var name = $(this).val();
			if (name == "" || name == null) {
				$("#dept").after("<span id='dept_msg' style='color: red'>所属学院不能为空</span>");
			}
	});

$("#addtime").blur(
		function() {
			$("#addtime_msg").empty();
			var name = $(this).val();
			if (name == "" || name == null) {
				$("#addtime").after("<span id='addtime_msg' style='color: red'>创建日期不能为空</span>");
			}
	});

$("#contents").blur(
		function() {
			$("#contents_msg").empty();
			var name = $(this).val();
			if (name == "" || name == null) {
				$("#contents").after("<span id='contents_msg' style='color: red'>教室介绍不能为空</span>");
			}
	});







$('#sub').click(function(){
var roomsname = $("#roomsname").val();
var image = $("#image").val();
var cateid = $("#cateid").val();
var manager = $("#manager").val();
var address = $("#address").val();
var contact = $("#contact").val();
var dept = $("#dept").val();
var addtime = $("#addtime").val();
var contents = $("#contents").val();
$("#roomsname_msg").empty();
$("#image_msg").empty();
$("#cateid_msg").empty();
$("#manager_msg").empty();
$("#address_msg").empty();
$("#contact_msg").empty();
$("#dept_msg").empty();
$("#addtime_msg").empty();
$("#contents_msg").empty();
if (roomsname == "" || roomsname == null) {
	$("#roomsname").after("<span id='roomsname_msg' style='color: red'>教室名称不能为空</span>");
	return false;
}
if (image == "" || image == null) {
	$("#image").after("<span id='image_msg' style='color: red'>图片不能为空</span>");
	return false;
}
if (cateid == "" || cateid == null) {
	$("#cateid").after("<span id='cateid_msg' style='color: red'>教室类型不能为空</span>");
	return false;
}
if (manager == "" || manager == null) {
	$("#manager").after("<span id='manager_msg' style='color: red'>教室负责人不能为空</span>");
	return false;
}
if (address == "" || address == null) {
	$("#address").after("<span id='address_msg' style='color: red'>教室地址不能为空</span>");
	return false;
}
if (contact == "" || contact == null) {
	$("#contact").after("<span id='contact_msg' style='color: red'>联系方式不能为空</span>");
	return false;
}
if (dept == "" || dept == null) {
	$("#dept").after("<span id='dept_msg' style='color: red'>所属学院不能为空</span>");
	return false;
}
if (addtime == "" || addtime == null) {
	$("#addtime").after("<span id='addtime_msg' style='color: red'>创建日期不能为空</span>");
	return false;
}
if (contents == "" || contents == null) {
	$("#contents").after("<span id='contents_msg' style='color: red'>教室介绍不能为空</span>");
	return false;
}
});
$('#res').click(function() {
$("#roomsname_msg").empty();
$("#image_msg").empty();
$("#cateid_msg").empty();
$("#manager_msg").empty();
$("#address_msg").empty();
$("#contact_msg").empty();
$("#dept_msg").empty();
$("#addtime_msg").empty();
$("#contents_msg").empty();
});

});
